<%inherit file="/admin/account/base.html" />

<%block name="innav">
<li><a href="${ reverse_url('admin:user') }">${ _("User") }</a></li>
</%block>

<%block name="submain">

<div class="the-select">
  <div class="row-fluid">
    <ul class="span3 nav">
      <li>${ _("Group") }</li>
      <li><select id="group-select">
          <option value="all">${ _("All") }</option>
          % for G in GROUP_LIST:
          <option value="${ G.id }">${ G.name }</option>
          % endfor
        </select></li>
    </ul>

    <ul class="span3 nav">
      <li>${ _("Sort") }</li>
      <li><select id="sortby-select">
          <option value="default">${ _("Default") }</option>
          <option value="id">ID</option>
          <option value="username">${ _("Username") }</option>
          <option value="last_active">${ _("Last Active") }</option>
      </select></li>
    </ul>

    <ul class="span3 nav">
      <li>${ _("Order") }</li>
      <li><select id="order-select">
          <option value="0">${ _("Descending") }</option>
          <option value="1">${ _("Ascending") }</option>
      </select></li>
    </ul>

    <div class="span3">
      <a class="btn" href="${ reverse_url('admin:user:add') }"><i class="icon-plus"></i> ${ _("Create New User") }</a>
      <a class="btn" href="${ reverse_url('admin:user:resource:all_add') }"><i class="icon-plus"></i> ${ _("Add Resource For All User") }</a>
    </div>

  </div>
</div>

<div class="input-prepend user-search">
  <span class="add-on">${ _("Search") }</span>
  <input class="span2" id="prependedInput" type="text" placeholder="${ _('username, email address') }">
</div>

<script type="text/javascript">
  y_input_search( ".user-search input", "${ urlupdate({'search': 'REPLACEOBJ', 'p': 1, 'ajax': 'true' }) }", "#aul" );
</script>


<script type="text/javascript">
  selected_reload( "#group-select", "${ urlupdate({'gid': 'REPLACEOBJ', 'p': 1 }) }" )
  selected_reload( "#sortby-select", "${ urlupdate({'by': 'REPLACEOBJ'}) }" )
  selected_reload( "#order-select", "${ urlupdate({'order': 'REPLACEOBJ'}) }" )

  $("#group-select option[value='${ GID }']").attr('selected', 'selected');
  $("#sortby-select option[value='${ SORT_BY }']").attr('selected', 'selected');
  $("#order-select option[value='${ ORDER }']").attr('selected', 'selected');
</script>

<p class="desc-title">${ _('Total : ') }${ TOTAL_USER }</p>

<div id="aul">

  <table class="table table-striped table-bordered">
    <thead>
      <tr>
        <th>${ _("ID") }</th>
        <th>${ _("Name") }</th>
        <th>${ _("Appliance") }</th>
        <th>${ _("Instance") }</th>
        <th>${ _("Email") }</th>
        <th>${ _("Last Active") }</th>
      </tr>
    </thead>
    <tbody>
      % for U in USER_LIST:
      <tr>
        <td>${ U.id }</td>
        <td class="username">
          ${ U.avatar_mini }
          <a class="action" href="${ reverse_url('admin:user:view') }?id=${ U.id }">${ U.username }</a>
        </td>
        <td>
          % if U.appliances:
          <a href="${ reverse_url('admin:appliance') }?uid=${ U.id }">${ len(U.appliances) }</a>
          % endif
        </td>
        <td>
          % if U.instances:
          <a href="${ reverse_url('admin:instance') }?uid=${ U.id }">${ len(U.instances) }</a>
          % endif
        </td>
        <td>${ U.email }</td>
        <td class="time">${ htime(U.last_active) }</td>
      </tr>
      % endfor
    </tbody>
  </table>
  ${ PAGE_HTML }

</div>

</%block>
